<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>利用QML实现无边框窗体，要求可移动，可缩放 | Xing's Blog</title><meta name="author" content="xing"><meta name="copyright" content="xing"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="利用QML实现无边框窗体，要求可移动，可缩放">
<meta property="og:type" content="article">
<meta property="og:title" content="利用QML实现无边框窗体，要求可移动，可缩放">
<meta property="og:url" content="https://veryxing.github.io/article/37bece30.html">
<meta property="og:site_name" content="Xing&#39;s Blog">
<meta property="og:description" content="利用QML实现无边框窗体，要求可移动，可缩放">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-3.png">
<meta property="article:published_time" content="2024-10-14T04:50:04.000Z">
<meta property="article:modified_time" content="2024-10-31T15:22:21.522Z">
<meta property="article:author" content="xing">
<meta property="article:tag" content="PyQt">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-3.png"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="https://veryxing.github.io/article/37bece30.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css"><script>
    (() => {
      
    const saveToLocal = {
      set: (key, value, ttl) => {
        if (!ttl) return
        const expiry = Date.now() + ttl * 86400000
        localStorage.setItem(key, JSON.stringify({ value, expiry }))
      },
      get: key => {
        const itemStr = localStorage.getItem(key)
        if (!itemStr) return undefined
        const { value, expiry } = JSON.parse(itemStr)
        if (Date.now() > expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return value
      }
    }

    window.btf = {
      saveToLocal,
      getScript: (url, attr = {}) => new Promise((resolve, reject) => {
        const script = document.createElement('script')
        script.src = url
        script.async = true
        Object.entries(attr).forEach(([key, val]) => script.setAttribute(key, val))
        script.onload = script.onreadystatechange = () => {
          if (!script.readyState || /loaded|complete/.test(script.readyState)) resolve()
        }
        script.onerror = reject
        document.head.appendChild(script)
      }),
      getCSS: (url, id) => new Promise((resolve, reject) => {
        const link = document.createElement('link')
        link.rel = 'stylesheet'
        link.href = url
        if (id) link.id = id
        link.onload = link.onreadystatechange = () => {
          if (!link.readyState || /loaded|complete/.test(link.readyState)) resolve()
        }
        link.onerror = reject
        document.head.appendChild(link)
      }),
      addGlobalFn: (key, fn, name = false, parent = window) => {
        if (!true && key.startsWith('pjax')) return
        const globalFn = parent.globalFn || {}
        globalFn[key] = globalFn[key] || {}
        if (name && globalFn[key][name]) return
        globalFn[key][name || Object.keys(globalFn[key]).length] = fn
        parent.globalFn = globalFn
      }
    }
  
      
      const activateDarkMode = () => {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      const activateLightMode = () => {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }

      btf.activateDarkMode = activateDarkMode
      btf.activateLightMode = activateLightMode

      const theme = saveToLocal.get('theme')
    
          theme === 'dark' ? activateDarkMode() : theme === 'light' ? activateLightMode() : null
        
      
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        document.documentElement.classList.toggle('hide-aside', asideStatus === 'hide')
      }
    
      
    const detectApple = () => {
      if (/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)) {
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
  
    })()
  </script><script>const GLOBAL_CONFIG = {
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.json","preload":false,"top_n_per_article":1,"unescape":false,"languages":{"hits_empty":"未找到符合您查询的内容：${query}","hits_stats":"共找到 ${hits} 篇文章"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlight.js","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false,"highlightFullpage":false,"highlightMacStyle":true},
  copy: {
    success: '复制成功',
    error: '复制失败',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'null',
  Snackbar: undefined,
  infinitegrid: {
    js: 'https://cdn.jsdelivr.net/npm/@egjs/infinitegrid/dist/infinitegrid.min.js',
    buttonText: '加载更多'
  },
  isPhotoFigcaption: false,
  islazyload: true,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '利用QML实现无边框窗体，要求可移动，可缩放',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2024-10-31 23:22:21'
}</script><meta name="generator" content="Hexo 7.3.0"><link rel="alternate" href="/atom.xml" title="Xing's Blog" type="application/atom+xml">
</head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src= "/images/2.gif" data-lazy-src="/img/butterfly-icon.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">59</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">55</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">9</div></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/gallery/"><i class="fa-fw fas fa-folder-open"></i><span> 图库</span></a></div><div class="menus_item"><a class="site-page" href="/shuoshuo/"><i class="fa-fw fas fa-folder-open"></i><span> 说说</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url(https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-3.png);"><nav id="nav"><span id="blog-info"><a class="nav-site-title" href="/"><span class="site-name">Xing's Blog</span></a><a class="nav-page-title" href="/"><span class="site-name">利用QML实现无边框窗体，要求可移动，可缩放</span></a></span><div id="menus"><div id="search-button"><span class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></span></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/gallery/"><i class="fa-fw fas fa-folder-open"></i><span> 图库</span></a></div><div class="menus_item"><a class="site-page" href="/shuoshuo/"><i class="fa-fw fas fa-folder-open"></i><span> 说说</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><span class="site-page"><i class="fas fa-bars fa-fw"></i></span></div></div></nav><div id="post-info"><h1 class="post-title">利用QML实现无边框窗体，要求可移动，可缩放</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2024-10-14T04:50:04.000Z" title="发表于 2024-10-14 12:50:04">2024-10-14</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2024-10-31T15:22:21.522Z" title="更新于 2024-10-31 23:22:21">2024-10-31</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/PyQt/">PyQt</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title=""><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">浏览量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h2 id="一，需求"><a href="#一，需求" class="headerlink" title="一，需求"></a>一，需求</h2><p>利用QML实现无边框窗体，要求可移动，可缩放。</p>
<h2 id="二，效果"><a href="#二，效果" class="headerlink" title="二，效果"></a>二，效果</h2><p><img src= "/images/2.gif" data-lazy-src="/assets/ai.gif" alt="img"></p>
<h2 id="三，实现"><a href="#三，实现" class="headerlink" title="三，实现"></a>三，实现</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br><span class="line">280</span><br><span class="line">281</span><br><span class="line">282</span><br><span class="line">283</span><br><span class="line">284</span><br><span class="line">285</span><br><span class="line">286</span><br><span class="line">287</span><br><span class="line">288</span><br><span class="line">289</span><br><span class="line">290</span><br><span class="line">291</span><br><span class="line">292</span><br><span class="line">293</span><br><span class="line">294</span><br><span class="line">295</span><br><span class="line">296</span><br><span class="line">297</span><br><span class="line">298</span><br><span class="line">299</span><br><span class="line">300</span><br><span class="line">301</span><br><span class="line">302</span><br><span class="line">303</span><br><span class="line">304</span><br><span class="line">305</span><br><span class="line">306</span><br><span class="line">307</span><br><span class="line">308</span><br><span class="line">309</span><br><span class="line">310</span><br><span class="line">311</span><br><span class="line">312</span><br><span class="line">313</span><br><span class="line">314</span><br><span class="line">315</span><br><span class="line">316</span><br><span class="line">317</span><br><span class="line">318</span><br><span class="line">319</span><br><span class="line">320</span><br><span class="line">321</span><br><span class="line">322</span><br><span class="line">323</span><br><span class="line">324</span><br><span class="line">325</span><br><span class="line">326</span><br><span class="line">327</span><br><span class="line">328</span><br><span class="line">329</span><br><span class="line">330</span><br><span class="line">331</span><br><span class="line">332</span><br><span class="line">333</span><br><span class="line">334</span><br><span class="line">335</span><br><span class="line">336</span><br><span class="line">337</span><br><span class="line">338</span><br><span class="line">339</span><br><span class="line">340</span><br><span class="line">341</span><br><span class="line">342</span><br><span class="line">343</span><br><span class="line">344</span><br><span class="line">345</span><br><span class="line">346</span><br><span class="line">347</span><br><span class="line">348</span><br><span class="line">349</span><br><span class="line">350</span><br><span class="line">351</span><br><span class="line">352</span><br><span class="line">353</span><br><span class="line">354</span><br><span class="line">355</span><br><span class="line">356</span><br><span class="line">357</span><br><span class="line">358</span><br><span class="line">359</span><br><span class="line">360</span><br><span class="line">361</span><br><span class="line">362</span><br><span class="line">363</span><br><span class="line">364</span><br><span class="line">365</span><br><span class="line">366</span><br><span class="line">367</span><br><span class="line">368</span><br><span class="line">369</span><br><span class="line">370</span><br><span class="line">371</span><br><span class="line">372</span><br><span class="line">373</span><br><span class="line">374</span><br><span class="line">375</span><br><span class="line">376</span><br><span class="line">377</span><br><span class="line">378</span><br><span class="line">379</span><br><span class="line">380</span><br><span class="line">381</span><br><span class="line">382</span><br><span class="line">383</span><br><span class="line">384</span><br><span class="line">385</span><br><span class="line">386</span><br><span class="line">387</span><br><span class="line">388</span><br><span class="line">389</span><br><span class="line">390</span><br><span class="line">391</span><br><span class="line">392</span><br><span class="line">393</span><br><span class="line">394</span><br><span class="line">395</span><br><span class="line">396</span><br><span class="line">397</span><br><span class="line">398</span><br><span class="line">399</span><br><span class="line">400</span><br><span class="line">401</span><br><span class="line">402</span><br><span class="line">403</span><br><span class="line">404</span><br><span class="line">405</span><br><span class="line">406</span><br><span class="line">407</span><br><span class="line">408</span><br><span class="line">409</span><br><span class="line">410</span><br><span class="line">411</span><br><span class="line">412</span><br><span class="line">413</span><br><span class="line">414</span><br></pre></td><td class="code"><pre><span class="line">//主窗体</span><br><span class="line"><span class="keyword">import</span> QtQuick <span class="number">2.12</span></span><br><span class="line"><span class="keyword">import</span> QtQuick.Controls <span class="number">2.3</span></span><br><span class="line"><span class="keyword">import</span> QtQuick.Window <span class="number">2.3</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> <span class="string">&quot;./widget&quot;</span></span><br><span class="line"></span><br><span class="line">Window  &#123;</span><br><span class="line">    <span class="built_in">id</span>: window</span><br><span class="line">    visible: true</span><br><span class="line">    flags: Qt.FramelessWindowHint|Qt.Window</span><br><span class="line">    width: <span class="number">1024</span></span><br><span class="line">    height: <span class="number">768</span></span><br><span class="line">    color: <span class="string">&quot;#0F1013&quot;</span></span><br><span class="line">    <span class="built_in">property</span> <span class="built_in">int</span> bw: <span class="number">3</span></span><br><span class="line"></span><br><span class="line">    //改变鼠标形状</span><br><span class="line">    MouseArea &#123;</span><br><span class="line">        anchors.fill: parent</span><br><span class="line">        hoverEnabled: true</span><br><span class="line">        cursorShape: &#123;</span><br><span class="line">            const p = Qt.point(mouseX, mouseY)</span><br><span class="line">            const b = bw + <span class="number">10</span></span><br><span class="line">            <span class="keyword">if</span> (p.x &lt; b &amp;&amp; p.y &lt; b) <span class="keyword">return</span> Qt.SizeFDiagCursor</span><br><span class="line">            <span class="keyword">if</span> (p.x &gt;= width - b &amp;&amp; p.y &gt;= height - b) <span class="keyword">return</span> Qt.SizeFDiagCursor</span><br><span class="line">            <span class="keyword">if</span> (p.x &gt;= width - b &amp;&amp; p.y &lt; b) <span class="keyword">return</span> Qt.SizeBDiagCursor</span><br><span class="line">            <span class="keyword">if</span> (p.x &lt; b &amp;&amp; p.y &gt;= height - b) <span class="keyword">return</span> Qt.SizeBDiagCursor</span><br><span class="line">            <span class="keyword">if</span> (p.x &lt; b || p.x &gt;= width - b) <span class="keyword">return</span> Qt.SizeHorCursor</span><br><span class="line">            <span class="keyword">if</span> (p.y &lt; b || p.y &gt;= height - b) <span class="keyword">return</span> Qt.SizeVerCursor</span><br><span class="line">        &#125;</span><br><span class="line">        acceptedButtons: Qt.NoButton</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    DragHandler &#123;</span><br><span class="line">        <span class="built_in">id</span>: resizeHandler</span><br><span class="line">        grabPermissions: TapHandler.TakeOverForbidden</span><br><span class="line">        target: null</span><br><span class="line">        onActiveChanged: <span class="keyword">if</span> (active) &#123;</span><br><span class="line">            const p = resizeHandler.centroid.position</span><br><span class="line">            const b = bw + <span class="number">10</span></span><br><span class="line">            let e = <span class="number">0</span>;</span><br><span class="line">            <span class="keyword">if</span> (p.x &lt; b) &#123; e |= Qt.LeftEdge &#125;</span><br><span class="line">            <span class="keyword">if</span> (p.x &gt;= width - b) &#123; e |= Qt.RightEdge &#125;</span><br><span class="line">            <span class="keyword">if</span> (p.y &lt; b) &#123; e |= Qt.TopEdge &#125;</span><br><span class="line">            <span class="keyword">if</span> (p.y &gt;= height - b) &#123; e |= Qt.BottomEdge &#125;</span><br><span class="line">            window.startSystemResize(e);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    MyToolBar&#123;</span><br><span class="line">        window:window</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">//工具栏</span><br><span class="line"><span class="keyword">import</span> QtQuick <span class="number">2.12</span></span><br><span class="line"><span class="keyword">import</span> QtQuick.Controls <span class="number">2.3</span></span><br><span class="line"><span class="keyword">import</span> QtQuick.Window <span class="number">2.3</span></span><br><span class="line"></span><br><span class="line">ToolBar &#123;</span><br><span class="line">    height: <span class="number">50</span></span><br><span class="line">    anchors.top: parent.top</span><br><span class="line">    anchors.left: parent.left</span><br><span class="line">    anchors.right: parent.right</span><br><span class="line">    x:bw</span><br><span class="line">    y:bw</span><br><span class="line"></span><br><span class="line">    <span class="built_in">property</span> var window: null</span><br><span class="line">    //关闭 最大化 最小化按钮</span><br><span class="line">    function toggleMaximized(mode) &#123;</span><br><span class="line">        <span class="keyword">if</span>(mode===<span class="number">0</span>)&#123;</span><br><span class="line">            <span class="keyword">if</span> (window.visibility === Window.Maximized) &#123;</span><br><span class="line">                window.showNormal();</span><br><span class="line">            &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                window.showMaximized();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;<span class="keyword">else</span> <span class="keyword">if</span>(mode===<span class="number">1</span>)&#123;</span><br><span class="line">            window.showMinimized()</span><br><span class="line">        &#125;<span class="keyword">else</span> <span class="keyword">if</span>(mode===<span class="number">2</span>)&#123;</span><br><span class="line">            window.close()</span><br><span class="line">        &#125;<span class="keyword">else</span> <span class="keyword">if</span>(mode===<span class="number">4</span>)&#123;</span><br><span class="line">            <span class="keyword">return</span> window.visibility</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    Rectangle&#123;</span><br><span class="line">        <span class="built_in">id</span>:rectBk</span><br><span class="line">        anchors.fill: parent</span><br><span class="line">        color: <span class="string">&quot;#1F2025&quot;</span></span><br><span class="line">        MouseArea &#123;</span><br><span class="line">            anchors.fill: parent</span><br><span class="line">            acceptedButtons: Qt.LeftButton</span><br><span class="line">            <span class="built_in">property</span> point clickPos: <span class="string">&quot;0,0&quot;</span></span><br><span class="line">            onPressed: &#123;</span><br><span class="line">                clickPos = Qt.point(mouse.x, mouse.y)</span><br><span class="line">            &#125;</span><br><span class="line">            onDoubleClicked: &#123;</span><br><span class="line">                toggleMaximized(<span class="number">0</span>)</span><br><span class="line">            &#125;</span><br><span class="line">            onPositionChanged: &#123;</span><br><span class="line">                //鼠标偏移量</span><br><span class="line">                var delta = Qt.point(mouse.x-clickPos.x, mouse.y-clickPos.y)</span><br><span class="line"></span><br><span class="line">                window.setX(window.x+delta.x)</span><br><span class="line">                window.setY(window.y+delta.y)</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    Row&#123;</span><br><span class="line">        anchors.right: parent.right</span><br><span class="line">        anchors.top: parent.top</span><br><span class="line">        anchors.bottom: parent.bottom</span><br><span class="line">        spacing: <span class="number">0</span></span><br><span class="line">        Rectangle&#123;</span><br><span class="line">            width: <span class="number">50</span></span><br><span class="line">            height: <span class="number">50</span></span><br><span class="line">            color: Qt.rgba(<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>)</span><br><span class="line">            Image &#123;</span><br><span class="line">                anchors.centerIn: parent</span><br><span class="line">                <span class="built_in">id</span>: <span class="built_in">min</span></span><br><span class="line">                source: <span class="string">&quot;qrc:/image/icon/minus.png&quot;</span></span><br><span class="line">                width: <span class="number">26</span></span><br><span class="line">                height: <span class="number">26</span></span><br><span class="line">            &#125;</span><br><span class="line">            MouseArea&#123;</span><br><span class="line">                anchors.fill: parent</span><br><span class="line">                hoverEnabled: true</span><br><span class="line">                onClicked: &#123;</span><br><span class="line">                    toggleMaximized(<span class="number">1</span>)</span><br><span class="line">                &#125;</span><br><span class="line">                onEntered: &#123;</span><br><span class="line">                    parent.color = <span class="string">&quot;#454B57&quot;</span></span><br><span class="line">                &#125;</span><br><span class="line"></span><br><span class="line">                onExited: &#123;</span><br><span class="line">                    parent.color = Qt.rgba(<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>)</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        Rectangle&#123;</span><br><span class="line">            width: <span class="number">50</span></span><br><span class="line">            height: <span class="number">50</span></span><br><span class="line">            color: Qt.rgba(<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>)</span><br><span class="line">            Image &#123;</span><br><span class="line">                <span class="built_in">id</span>: <span class="built_in">max</span></span><br><span class="line">                source: (toggleMaximized(<span class="number">4</span>) === Window.Maximized)?<span class="string">&quot;qrc:/image/icon/maximize.png&quot;</span>:<span class="string">&quot;qrc:/image/icon/maximize2.png&quot;</span></span><br><span class="line">                anchors.centerIn: parent</span><br><span class="line">                width: <span class="number">26</span></span><br><span class="line">                height: <span class="number">26</span></span><br><span class="line">            &#125;</span><br><span class="line">            MouseArea&#123;</span><br><span class="line">                anchors.fill: parent</span><br><span class="line">                hoverEnabled: true</span><br><span class="line">                onClicked: &#123;</span><br><span class="line">                    console.log(<span class="string">&quot;max&quot;</span>)</span><br><span class="line">                    toggleMaximized(<span class="number">0</span>)</span><br><span class="line">                &#125;</span><br><span class="line">                onEntered: &#123;</span><br><span class="line">                    parent.color = <span class="string">&quot;#454B57&quot;</span></span><br><span class="line">                &#125;</span><br><span class="line">                onExited: &#123;</span><br><span class="line">                    parent.color = Qt.rgba(<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>)</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        Rectangle&#123;</span><br><span class="line">            width: <span class="number">50</span></span><br><span class="line">            height: <span class="number">50</span></span><br><span class="line">            color: Qt.rgba(<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>)</span><br><span class="line">            Image &#123;</span><br><span class="line">                <span class="built_in">id</span>: close</span><br><span class="line">                source: <span class="string">&quot;qrc:/image/icon/close.png&quot;</span></span><br><span class="line">                anchors.centerIn: parent</span><br><span class="line">                width: <span class="number">26</span></span><br><span class="line">                height: <span class="number">26</span></span><br><span class="line">            &#125;</span><br><span class="line">            MouseArea&#123;</span><br><span class="line">                anchors.fill: parent</span><br><span class="line">                hoverEnabled: true</span><br><span class="line">                onClicked: &#123;</span><br><span class="line">                    toggleMaximized(<span class="number">2</span>)</span><br><span class="line">                &#125;</span><br><span class="line">                onEntered: &#123;</span><br><span class="line">                    parent.color = <span class="string">&quot;#454B57&quot;</span></span><br><span class="line">                &#125;</span><br><span class="line"></span><br><span class="line">                onExited: &#123;</span><br><span class="line">                    parent.color = Qt.rgba(<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>)</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    //标题</span><br><span class="line">    Text &#123;</span><br><span class="line">        <span class="built_in">id</span>:title</span><br><span class="line">        anchors.left: parent.left</span><br><span class="line">        anchors.verticalCenter:  parent.verticalCenter</span><br><span class="line">        anchors.leftMargin: <span class="number">20</span></span><br><span class="line">        color: <span class="string">&quot;#FFFFFF&quot;</span></span><br><span class="line">        font.pixelSize: <span class="number">24</span></span><br><span class="line">        text: qsTr(<span class="string">&quot;影像检测仪&quot;</span>)</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    Menu &#123;</span><br><span class="line">        <span class="built_in">id</span>:settingMenu</span><br><span class="line">        x:setting.x</span><br><span class="line">        y:setting.y+setting.height+<span class="number">1</span></span><br><span class="line">        width: <span class="number">120</span></span><br><span class="line">        Action &#123;</span><br><span class="line">            text: qsTr(<span class="string">&quot;创建项目&quot;</span>)</span><br><span class="line">            onTriggered: console.log(<span class="string">&quot;创建项目&quot;</span>)</span><br><span class="line"></span><br><span class="line">        &#125;</span><br><span class="line">        Action &#123;</span><br><span class="line">            text: qsTr(<span class="string">&quot;编辑项目&quot;</span>)</span><br><span class="line">            onTriggered: console.log(<span class="string">&quot;编辑项目&quot;</span>)</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        delegate: MenuBarItem &#123;</span><br><span class="line">            <span class="built_in">id</span>: settingMenuItem</span><br><span class="line">            height: <span class="number">40</span></span><br><span class="line">            width: <span class="number">120</span></span><br><span class="line"></span><br><span class="line">            contentItem: Text &#123;</span><br><span class="line">                text: settingMenuItem.text</span><br><span class="line">                font.pixelSize: <span class="number">16</span></span><br><span class="line">                color:  <span class="string">&quot;#ffffff&quot;</span></span><br><span class="line">                horizontalAlignment: Text.AlignHCenter</span><br><span class="line">                verticalAlignment: Text.AlignVCenter</span><br><span class="line">                elide: Text.ElideRight</span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line">            background: Rectangle &#123;</span><br><span class="line">                implicitWidth: <span class="number">120</span></span><br><span class="line">                implicitHeight: <span class="number">40</span></span><br><span class="line">                color: Qt.rgba(<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>)</span><br><span class="line">                MouseArea&#123;</span><br><span class="line">                    anchors.fill: parent</span><br><span class="line">                    hoverEnabled: true</span><br><span class="line">                    propagateComposedEvents: true</span><br><span class="line">                    onClicked: &#123;</span><br><span class="line">                        settingMenu.close()</span><br><span class="line">                        settingMenuItem.action.trigger()</span><br><span class="line">                    &#125;</span><br><span class="line">                    onEntered: &#123;</span><br><span class="line">                        parent.color = <span class="string">&quot;#454B57&quot;</span></span><br><span class="line">                    &#125;</span><br><span class="line"></span><br><span class="line">                    onExited: &#123;</span><br><span class="line">                        parent.color = Qt.rgba(<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>)</span><br><span class="line">                    &#125;</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        background: Rectangle &#123;</span><br><span class="line">            implicitWidth: <span class="number">150</span></span><br><span class="line">            implicitHeight: <span class="number">40</span></span><br><span class="line">            color: <span class="string">&quot;#1F2025&quot;</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    //设置</span><br><span class="line">    Rectangle&#123;</span><br><span class="line">        <span class="built_in">id</span>:setting</span><br><span class="line">        anchors.top: parent.top</span><br><span class="line">        anchors.bottom: parent.bottom</span><br><span class="line">        anchors.left:title.right</span><br><span class="line">        anchors.leftMargin: <span class="number">100</span></span><br><span class="line">        color: Qt.rgba(<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>)</span><br><span class="line">        width: <span class="number">100</span></span><br><span class="line"></span><br><span class="line">        Row&#123;</span><br><span class="line">            anchors.centerIn: parent</span><br><span class="line">            spacing: <span class="number">2</span></span><br><span class="line">            Text &#123;</span><br><span class="line">                color: <span class="string">&quot;#FFFFFF&quot;</span></span><br><span class="line">                font.pixelSize: <span class="number">20</span></span><br><span class="line">                text: qsTr(<span class="string">&quot;设置&quot;</span>)</span><br><span class="line">                verticalAlignment: Text.AlignVCenter</span><br><span class="line">                anchors.verticalCenter: parent.verticalCenter</span><br><span class="line">            &#125;</span><br><span class="line">            Image &#123;</span><br><span class="line">                width: <span class="number">32</span></span><br><span class="line">                height: <span class="number">32</span></span><br><span class="line">                anchors.verticalCenter: parent.verticalCenter</span><br><span class="line">                source: <span class="string">&quot;qrc:/image/icon/down.png&quot;</span></span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        MouseArea&#123;</span><br><span class="line">            anchors.fill: parent</span><br><span class="line">            hoverEnabled: true</span><br><span class="line">            propagateComposedEvents: true</span><br><span class="line">            onClicked: &#123;</span><br><span class="line">                settingMenu.<span class="built_in">open</span>()</span><br><span class="line">            &#125;</span><br><span class="line">            onEntered: &#123;</span><br><span class="line">                parent.color = <span class="string">&quot;#454B57&quot;</span></span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line">            onExited: &#123;</span><br><span class="line">                parent.color = Qt.rgba(<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>)</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    //关于菜单</span><br><span class="line">    Menu &#123;</span><br><span class="line">        <span class="built_in">id</span>:aboutMenu</span><br><span class="line">        x:about.x</span><br><span class="line">        y:about.y+about.height+<span class="number">1</span></span><br><span class="line">        width: <span class="number">120</span></span><br><span class="line">        Action &#123;</span><br><span class="line">            text: qsTr(<span class="string">&quot;关于这个&quot;</span>)</span><br><span class="line">            onTriggered: console.log(<span class="string">&quot;关于这个&quot;</span>)</span><br><span class="line">        &#125;</span><br><span class="line">        Action &#123;</span><br><span class="line">            text: qsTr(<span class="string">&quot;关于那个&quot;</span>)</span><br><span class="line">            onTriggered: console.log(<span class="string">&quot;关于那个&quot;</span>)</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        delegate: MenuBarItem &#123;</span><br><span class="line">            <span class="built_in">id</span>: aboutMenuItem</span><br><span class="line">            height: <span class="number">40</span></span><br><span class="line">            width: <span class="number">120</span></span><br><span class="line"></span><br><span class="line">            contentItem: Text &#123;</span><br><span class="line">                text: aboutMenuItem.text</span><br><span class="line">                font.pixelSize: <span class="number">16</span></span><br><span class="line">                color:  <span class="string">&quot;#ffffff&quot;</span></span><br><span class="line">                horizontalAlignment: Text.AlignHCenter</span><br><span class="line">                verticalAlignment: Text.AlignVCenter</span><br><span class="line">                elide: Text.ElideRight</span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line">            background: Rectangle &#123;</span><br><span class="line">                implicitWidth: <span class="number">120</span></span><br><span class="line">                implicitHeight: <span class="number">40</span></span><br><span class="line">                color: Qt.rgba(<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>)</span><br><span class="line">                MouseArea&#123;</span><br><span class="line">                    anchors.fill: parent</span><br><span class="line">                    hoverEnabled: true</span><br><span class="line">                    propagateComposedEvents: true</span><br><span class="line">                    onClicked: &#123;</span><br><span class="line">                        aboutMenu.close()</span><br><span class="line">                        aboutMenuItem.action.trigger()</span><br><span class="line">                    &#125;</span><br><span class="line">                    onEntered: &#123;</span><br><span class="line">                        parent.color = <span class="string">&quot;#454B57&quot;</span></span><br><span class="line">                    &#125;</span><br><span class="line"></span><br><span class="line">                    onExited: &#123;</span><br><span class="line">                        parent.color = Qt.rgba(<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>)</span><br><span class="line">                    &#125;</span><br><span class="line">                &#125;</span><br><span class="line"></span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line">        &#125;</span><br><span class="line">        background: Rectangle &#123;</span><br><span class="line">            implicitWidth: <span class="number">150</span></span><br><span class="line">            implicitHeight: <span class="number">40</span></span><br><span class="line">            color: <span class="string">&quot;#1F2025&quot;</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    //关于</span><br><span class="line">    Rectangle&#123;</span><br><span class="line">        <span class="built_in">id</span>:about</span><br><span class="line">        anchors.top: parent.top</span><br><span class="line">        anchors.bottom: parent.bottom</span><br><span class="line">        anchors.left:setting.right</span><br><span class="line">        color: Qt.rgba(<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>)</span><br><span class="line">        width: <span class="number">100</span></span><br><span class="line"></span><br><span class="line">        Row&#123;</span><br><span class="line">            anchors.centerIn: parent</span><br><span class="line">            spacing: <span class="number">2</span></span><br><span class="line">            Text &#123;</span><br><span class="line">                color: <span class="string">&quot;#FFFFFF&quot;</span></span><br><span class="line">                font.pixelSize: <span class="number">20</span></span><br><span class="line">                text: qsTr(<span class="string">&quot;关于&quot;</span>)</span><br><span class="line">                verticalAlignment: Text.AlignVCenter</span><br><span class="line">                anchors.verticalCenter: parent.verticalCenter</span><br><span class="line">            &#125;</span><br><span class="line">            Image &#123;</span><br><span class="line">                width: <span class="number">32</span></span><br><span class="line">                height: <span class="number">32</span></span><br><span class="line">                anchors.verticalCenter: parent.verticalCenter</span><br><span class="line">                source: <span class="string">&quot;qrc:/image/icon/down.png&quot;</span></span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        MouseArea&#123;</span><br><span class="line">            anchors.fill: parent</span><br><span class="line">            hoverEnabled: true</span><br><span class="line">            propagateComposedEvents: true</span><br><span class="line">            onClicked: &#123;</span><br><span class="line">                aboutMenu.<span class="built_in">open</span>()</span><br><span class="line">            &#125;</span><br><span class="line">            onEntered: &#123;</span><br><span class="line">                parent.color = <span class="string">&quot;#454B57&quot;</span></span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line">            onExited: &#123;</span><br><span class="line">                parent.color = Qt.rgba(<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>)</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta"><i class="fas fa-circle-user fa-fw"></i>文章作者: </span><span class="post-copyright-info"><a href="https://veryXing.github.io">xing</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta"><i class="fas fa-square-arrow-up-right fa-fw"></i>文章链接: </span><span class="post-copyright-info"><a href="https://veryxing.github.io/article/37bece30.html">https://veryxing.github.io/article/37bece30.html</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta"><i class="fas fa-circle-exclamation fa-fw"></i>版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来源 <a href="https://veryXing.github.io" target="_blank">Xing's Blog</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/PyQt/">PyQt</a></div><div class="post-share"><div class="social-share" data-image="https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-3.png" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><a class="prev-post pull-left" href="/article/0.html" title="pyqt5 无边框界面"><img class="cover" src= "/images/2.gif" data-lazy-src="https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-9.png" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">pyqt5 无边框界面</div></div></a><a class="next-post pull-right" href="/article/f5da021a.html" title="如何在Mac M1上快速安装PyQt5"><img class="cover" src= "/images/2.gif" data-lazy-src="https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-8.png" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">如何在Mac M1上快速安装PyQt5</div></div></a></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><a href="/article/2241662d.html" title="PyQt5窗口跟随其它窗口"><img class="cover" src= "/images/2.gif" data-lazy-src="https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-3.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2018-10-23</div><div class="title">PyQt5窗口跟随其它窗口</div></div></a><a href="/article/32b656da.html" title="PyQt密码管理系统"><img class="cover" src= "/images/2.gif" data-lazy-src="https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-2.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-10-20</div><div class="title">PyQt密码管理系统</div></div></a><a href="/article/f305b1cc.html" title="PyQt属性动画(QPropertyAnimation)"><img class="cover" src= "/images/2.gif" data-lazy-src="https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-4.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2019-05-08</div><div class="title">PyQt属性动画(QPropertyAnimation)</div></div></a><a href="/article/bf8fd827.html" title="QSS (Qt Style Sheet) 样式设定"><img class="cover" src= "/images/2.gif" data-lazy-src="https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-6.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-10-14</div><div class="title">QSS (Qt Style Sheet) 样式设定</div></div></a><a href="/article/5a4e93df.html" title="PyQt5动画边框阴影"><img class="cover" src= "/images/2.gif" data-lazy-src="https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-6.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2018-09-25</div><div class="title">PyQt5动画边框阴影</div></div></a><a href="/article/3217c859.html" title="三种方式绑定信号槽"><img class="cover" src= "/images/2.gif" data-lazy-src="https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-10.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2019-05-04</div><div class="title">三种方式绑定信号槽</div></div></a></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info is-center"><div class="avatar-img"><img src= "/images/2.gif" data-lazy-src="/img/butterfly-icon.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info-name">xing</div><div class="author-info-description"></div><div class="site-data"><a href="/archives/"><div class="headline">文章</div><div class="length-num">59</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">55</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">9</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/veryXing"><i class="fab fa-github"></i><span>Follow Me</span></a></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">This is my Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%80%EF%BC%8C%E9%9C%80%E6%B1%82"><span class="toc-number">1.</span> <span class="toc-text">一，需求</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BA%8C%EF%BC%8C%E6%95%88%E6%9E%9C"><span class="toc-number">2.</span> <span class="toc-text">二，效果</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%89%EF%BC%8C%E5%AE%9E%E7%8E%B0"><span class="toc-number">3.</span> <span class="toc-text">三，实现</span></a></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/article/18647ffa.html" title="pytest-qt 测试模态窗体."><img src= "/images/2.gif" data-lazy-src="https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-9.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="pytest-qt 测试模态窗体."/></a><div class="content"><a class="title" href="/article/18647ffa.html" title="pytest-qt 测试模态窗体.">pytest-qt 测试模态窗体.</a><time datetime="2024-11-27T17:01:35.284Z" title="发表于 2024-11-28 01:01:35">2024-11-28</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/article/5a8a6c8d.html" title="post"><img src= "/images/2.gif" data-lazy-src="http://up.36992.com/pic/e6/c5/51/e6c551e768092c8655292d89a4034a74.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="post"/></a><div class="content"><a class="title" href="/article/5a8a6c8d.html" title="post">post</a><time datetime="2024-10-31T15:27:17.000Z" title="发表于 2024-10-31 23:27:17">2024-10-31</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/article/140ab620.html" title="某网站自动下载音乐mp3和歌词"><img src= "/images/2.gif" data-lazy-src="https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-6.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="某网站自动下载音乐mp3和歌词"/></a><div class="content"><a class="title" href="/article/140ab620.html" title="某网站自动下载音乐mp3和歌词">某网站自动下载音乐mp3和歌词</a><time datetime="2024-10-31T12:15:16.000Z" title="发表于 2024-10-31 20:15:16">2024-10-31</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/article/32b656da.html" title="PyQt密码管理系统"><img src= "/images/2.gif" data-lazy-src="https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-2.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="PyQt密码管理系统"/></a><div class="content"><a class="title" href="/article/32b656da.html" title="PyQt密码管理系统">PyQt密码管理系统</a><time datetime="2024-10-20T14:36:18.000Z" title="发表于 2024-10-20 22:36:18">2024-10-20</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/article/a0a0fd82.html" title="PyQt5实现桌面小宠物"><img src= "/images/2.gif" data-lazy-src="https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-9.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="PyQt5实现桌面小宠物"/></a><div class="content"><a class="title" href="/article/a0a0fd82.html" title="PyQt5实现桌面小宠物">PyQt5实现桌面小宠物</a><time datetime="2024-10-20T14:28:05.000Z" title="发表于 2024-10-20 22:28:05">2024-10-20</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2019 - 2024 By xing</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="日间和夜间模式切换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside-config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><div class="js-pjax"></div><script defer="defer" id="ribbon" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/canvas-ribbon.min.js" size="150" alpha="0.6" zIndex="-1" mobile="true" data-click="false"></script><script src="https://cdn.jsdelivr.net/npm/pjax/pjax.min.js"></script><script>(() => {
  const pjaxSelectors = ["head > title","#config-diff","#body-wrap","#rightside-config-hide","#rightside-config-show",".js-pjax"]

  window.pjax = new Pjax({
    elements: 'a:not([target="_blank"])',
    selectors: pjaxSelectors,
    cacheBust: false,
    analytics: false,
    scrollRestoration: false
  })

  const triggerPjaxFn = (val) => {
    if (!val) return
    Object.values(val).forEach(fn => fn())
  }

  document.addEventListener('pjax:send', () => {
    // removeEventListener
    btf.removeGlobalFnEvent('pjaxSendOnce')
    btf.removeGlobalFnEvent('themeChange')

    // reset readmode
    const $bodyClassList = document.body.classList
    if ($bodyClassList.contains('read-mode')) $bodyClassList.remove('read-mode')

    triggerPjaxFn(window.globalFn.pjaxSend)
  })

  document.addEventListener('pjax:complete', () => {
    btf.removeGlobalFnEvent('pjaxCompleteOnce')
    document.querySelectorAll('script[data-pjax]').forEach(item => {
      const newScript = document.createElement('script')
      const content = item.text || item.textContent || item.innerHTML || ""
      Array.from(item.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value))
      newScript.appendChild(document.createTextNode(content))
      item.parentNode.replaceChild(newScript, item)
    })

    triggerPjaxFn(window.globalFn.pjaxComplete)
  })

  document.addEventListener('pjax:error', e => {
    if (e.request.status === 404) {
      pjax.loadUrl('/404.html')
    }
  })
})()</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div><div id="local-search-stats-wrap"></div></div></div><div id="search-mask"></div><script src="/js/search/local-search.js"></script></div></div></body></html>